/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.DAO;

import com.Entity.Project;
import com.Interface.ProjectInterface;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Vi
 */
@Stateless
public class ProjectDAO implements ProjectInterface{

    private EntityManager entityManager;
      
    public ProjectDAO() {
        EntityManagerFactory factory = Persistence.createEntityManagerFactory("persistenceUnit");
        entityManager = factory.createEntityManager();
    }
      
      
    @Override
    public List<Project> getAllProjects() {
        System.out.println("Pobieram");
        return (List<Project>) entityManager.createNamedQuery("Project.findAll").getResultList();
    }
    
}
